﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ReconCaracteres_Backpropagation
{
    class WeightsPool
    {
        public StreamReader reader;
        public WeightsPool() {
            
        }

        public Double[] readInputWeights(int neuronIndex, String fileName)
        {
            reader = new StreamReader(fileName);
            String line = "";
            String[] weightsLine = null;

            for (int i = 0; i <= neuronIndex; i++)
            {
                if ((line = reader.ReadLine()) != null && (line != "*"))
                {
                    weightsLine = line.Split(' ');
                }
            }
            Double[] weights = new Double[weightsLine.Count()];
            for (int i = 0; i < weightsLine.Count(); i++)
            {
                weights[i] = Double.Parse(weightsLine[i]);
            }
            reader.Close();
            return weights;
        }
        public Double[] readOutputWeights(int neuronIndex, String fileName)
        {
            reader = new StreamReader(fileName);
            String line = "";
            String[] weightsLine = null;
            while ((line = reader.ReadLine()) != null && (line != "*"))
            {
            }
            for (int i = 0; i <= neuronIndex; i++)
            {
                if ((line = reader.ReadLine()) != null)
                {
                    weightsLine = line.Split(' ');
                }
            }
            Double[] weights = new Double[weightsLine.Count()];
            for (int i = 0; i < weightsLine.Count(); i++)
            {
                weights[i] = Double.Parse(weightsLine[i]);
            }
            reader.Close();
            return weights;
        }

    }
}
